home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / tests / misc / helloworld.c next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  1.5 KB  |  72 lines

  1. /*
  2.  *  "Hello world" program for the EXODUS Storage Manager
  3.  * $RCSfile: helloworld.c,v $
  4.  * $Revision: 1.1.1.1 $
  5.  * $Date: 1996/05/04 21:56:07 $
  6.  *
  7.  *  This program sets configuration options, connects with a server
  8.  *  prints "hello world", and shuts down the client side of the
  9.  *  Storage Manager. 
  10.  */
  11.  
  12. #include "sm_client.h"
  13. #include <stdlib.h>
  14.  
  15.  
  16. void ErrorCheck (int, char *);
  17.  
  18. /*
  19.  *    Main program:
  20.  */
  21. main(int argc, char** argv)
  22. {
  23.  
  24.     int        e;
  25.     char    *errorMsg;
  26.     TID        tid;
  27.  
  28.     /* Read the default configuration files */
  29.     e = sm_ReadConfigFile(NULL, argv[0], &errorMsg);
  30.     if (e != esmNOERROR) {
  31.         fprintf(stderr, "Configuration file error: %s\n", errorMsg);
  32.         ErrorCheck(e, "sm_ReadConfigFile");
  33.         exit(0);
  34.     }
  35.  
  36.     /* Set any options from the command line */
  37.     e = sm_ParseCommandLine(&argc, argv, &errorMsg);
  38.     if (e != esmNOERROR) {
  39.         fprintf(stderr, "command line error: %s\n", errorMsg);
  40.         ErrorCheck(e, "sm_PargeCommandLine");
  41.         exit(0);
  42.     }
  43.  
  44.     /* Initialize the storage manager.  */
  45.     e = sm_Initialize();
  46.     ErrorCheck(e, "sm_Initialize");
  47.  
  48.     /*
  49.      *  A more complete program would now mount a volume,
  50.      *  and begin a transaction.
  51.      */
  52.  
  53.     printf("Hello world!\n");
  54.  
  55.     /* shut down the Storage Manager client */
  56.     e = sm_ShutDown( );
  57.     ErrorCheck(e, "sm_ShutDown");
  58. }
  59.  
  60.  
  61. void ErrorCheck ( int e, char *routine)
  62. {
  63.     if (e < 0) {
  64.         fprintf(stderr, "Got a Storage Manager error from %s\n", routine);
  65.         fprintf(stderr, "Error = %s\n", sm_Error(sm_errno));
  66.         exit(1);
  67.     }
  68. }
  69.  
  70.  
  71.  
  72.